﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections;

/**Class: QuestionCreatorForm
 * @Author Jayson Park
 * @version 0.99b
 * Course       : ITEC 4860 Spring 2012
 * Written      : March 20th, 2012
 * Last Revised : April 10th, 2012
 * 
 * This class is the underlying code for the form in which users can edit or add new questions.
 * 
 * Purpose: Pull questions from the database
 *          Create new questions and save to the database
 * */

namespace quizzer_linq_3
{
    public partial class QuestionCreatorForm : Form
    {
        //Instance of the Quizzer_Data_Access class in order to communicate with the database

        Quizzer_Data_Access dataAccess = new Quizzer_Data_Access();

        //ID of the user to find the questions from
        //Not implemented to pull questions specific to a user

        private int user_id;

        //Used to keep track of all the Question IDs within the QCQuestionSelectionComboBox

        private ArrayList questionIDList = new ArrayList();

        //Used to keep track of all the Category IDs within the QCCategoryComboBox

        private ArrayList questionCategoryIDList = new ArrayList();

        //Used to keep track of all the Category IDs within the QCSubcategoryComboBox

        private ArrayList questionSubCategoryIDList = new ArrayList();

        //Instance variables to be used in the save edited question scenario

        Boolean editing = false;

        //Used to keep track of the question ID of the question being edited

        private int editQuestionID;

        //Used to keep track of the Subcategory ID of the question being edited

        private int editSubCategoryID;

        //Used to store the rating when trying to edit questions

        int editRating;

        //Used to store the feedback when trying to edit questions

        String editFeedback;

        //Flag to see if there were any changes done to the question

        Boolean changesSaved = true;

        //When creating a new question, this is the initial rating given to the question

        int initRating = 0;

        //When creating a new question, this is the initial feedback given to the question

        String initFeedback = "No Feedback";

        //userid of the Administrator

        const int ADMIN_USER_ID = 1000;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //question ID when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_QUESTIONID_INDEX = 0;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //subcategory ID when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_SUBCATEGORYID_INDEX = 1;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //topic when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_TOPIC_INDEX = 2;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //question title when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_TITLE_INDEX = 3;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //difficulty level when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_DIFFICULTY_LEVEL_INDEX = 4;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //Public? boolean when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_PUBLIC_INDEX = 5;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //correct answer string when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_CORRECT_ANSWER_INDEX = 6;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //alternative answer 1 string when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_ALT_ANSWER1_INDEX = 7;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //alternative answer 2 string when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_ALT_ANSWER2_INDEX = 8;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //alternative answer 3 string when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_ALT_ANSWER3_INDEX = 9;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //alternative answer 4 string when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_ALT_ANSWER4_INDEX = 10;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //question rating when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_RATING_INDEX = 11;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //question feedback when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_FEEDBACK_INDEX = 12;

        //When pulling from the QDB using getQuestion methods, this is the index for the 
        //question professor when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_QUESTION_PROFESSOR_INDEX = 13;

        //When pulling from the QDB using getCategory methods, this is the index for the 
        //category id when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_CATEGORY_CATEGORYID_INDEX = 0;

        //When pulling from the QDB using getCategory methods, this is the index for the 
        //category name when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_CATEGORY_CATEGORYNAME_INDEX = 1;

        //When pulling from the QDB using getCategoryForSubcategory methods, this is the index for the 
        //subcategory id when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_CAT_SUBCAT_SUBCATEGORYID_INDEX = 0;

        //When pulling from the QDB using getCategoryForSubcategory methods, this is the index for the 
        //subcategory name when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_CAT_SUBCAT_SUBCATEGORY_NAME_INDEX = 1;

        //When pulling from the QDB using getCategoryForSubcategory methods, this is the index for the 
        //category id when splitting the returned string using the '|' delimiter.

        const int QUIZZERDB_CAT_SUBCAT_CATEGORYID_INDEX = 2;

        /**Constructor: QuestionCreatorForm()
         * Added this method as a general constructor for the QuestionCreatorForm
         * -SE
         * */

        public QuestionCreatorForm()
        {
            //Default Admin User
            user_id = ADMIN_USER_ID;
            InitializeComponent();
            populateQCQuestionSelectionComboBox();
            populateQCCategoryComboBox();
            setDefaultComboBoxValues();
            changesSaved = true;
        }

        /**Constructor: QuestionCreatorForm(int)
         * This is the Constructor to be used when the implementation of pulling and saving questions
         * based on user_id is done
         * @param user_id the id of the user that is editing or creating questions
         * */

        public QuestionCreatorForm(int user_id)
        {
            this.user_id = user_id;
            InitializeComponent();
            populateQCQuestionSelectionComboBox();
            populateQCCategoryComboBox();
            setDefaultComboBoxValues();
            changesSaved = true;
        }

        /**Method: setDefaultComboBoxValues
         * Sets the default index for combo boxes so the form controls are not blank when showing the form the first time
         */

        private void setDefaultComboBoxValues()
        {
            if (QCCategoryComboBox.Items.Count > 0)
            {
                QCCategoryComboBox.SelectedIndex = 0;
            }
            if (QCSubCategoryComboBox.Items.Count > 0)
            {
                QCSubCategoryComboBox.SelectedIndex = 0;
            }
            if (QCDifficultyLevelComboBox.Items.Count > 0)
            {
                QCDifficultyLevelComboBox.SelectedIndex = 0;
            }
            if (QCQuestionSelectionComboBox.Items.Count > 0)
            {
                QCQuestionSelectionComboBox.SelectedIndex = 0;
            }
        }

        /**Method: populateQCQuestionSelectionComboBox
         * This adds all of the questions to the Question Selection Combo Box (no user_id specific yet)
         */

        private void populateQCQuestionSelectionComboBox()
        {
            if (dataAccess.GetAllQuestion().Trim() != "")
            {
                String[] questions = dataAccess.GetAllQuestion().Trim().Split('\n');

                QCQuestionSelectionComboBox.Items.Clear();
                questionIDList.Clear();
                for (int questionCounter = 0; questionCounter < questions.Length; questionCounter++)
                {
                    if (user_id == int.Parse((string)((string)questions.GetValue(questionCounter)).Split('|').GetValue(QUIZZERDB_QUESTION_PROFESSOR_INDEX)) ||
                        user_id == ADMIN_USER_ID)
                    {
                        questionIDList.Add(int.Parse((String)((String)(questions.GetValue(questionCounter))).Split('|').GetValue(QUIZZERDB_QUESTION_QUESTIONID_INDEX)));
                        QCQuestionSelectionComboBox.Items.Add(((String)(questions.GetValue(questionCounter))).Split('|').GetValue(QUIZZERDB_QUESTION_TITLE_INDEX));
                    }
                }
            }
        }

        /**Method: populateQCCategoryComboBox
         * This populates the Category Combobox with all of the categories from the database.
         * Sets the current category to the first category added to the combo box.
         */

        private void populateQCCategoryComboBox()
        {
            QCCategoryComboBox.Items.Clear();
            questionCategoryIDList.Clear();

            String[] categories = dataAccess.GetAllCategory().Split('\n');

            for (int categoryCounter = 0; categoryCounter < categories.Length - 1; categoryCounter++)
            {
                QCCategoryComboBox.Items.Add(((String)(categories.GetValue(categoryCounter))).Split('|').GetValue(QUIZZERDB_CATEGORY_CATEGORYNAME_INDEX));
                questionCategoryIDList.Add(int.Parse((String)((String)(categories.GetValue(categoryCounter))).Split('|').GetValue(QUIZZERDB_CATEGORY_CATEGORYID_INDEX)));
            }
            if (QCCategoryComboBox.Items.Count > 0)
            {
                populateQCSubcategoryComboBox((int)questionCategoryIDList[0]);
            }
        }

        /**Method: populateQCSubcategoryComboBox
         * This populates the Subcategory Combobox with all of the Subcategories from the related Category.
         * Sets the current Subcategory to the first Subcategory added to the combo box.
         */

        private void populateQCSubcategoryComboBox(int currentCategory)
        {
            QCSubCategoryComboBox.Items.Clear();
            questionSubCategoryIDList.Clear();

            String[] subCategories = dataAccess.GetSubCategoryForCategory(currentCategory).Split('\n');

            for (int subCategoryCounter = 0; subCategoryCounter < subCategories.Length - 1; subCategoryCounter++)
            {
                QCSubCategoryComboBox.Items.Add(((String)(subCategories.GetValue(subCategoryCounter))).Split('|').GetValue(QUIZZERDB_CAT_SUBCAT_SUBCATEGORY_NAME_INDEX));
                questionSubCategoryIDList.Add(((String)(subCategories.GetValue(subCategoryCounter))).Split('|').GetValue(QUIZZERDB_CAT_SUBCAT_SUBCATEGORYID_INDEX));
            }
            if (QCSubCategoryComboBox.Items.Count > 0)
            {
                QCSubCategoryComboBox.SelectedIndex = 0;
            }
        }

        /**Method: QCEditButton - Click
         * Also raises a flag that this is a question being edited, not a new question
         * This method also calls the checkSaved() method to see if the user has saved the current question.
         * Calls the method to populate fields with the question to edit.
         */

        private void QCEditButton_Click(object sender, EventArgs e)
        {
            if (QCQuestionSelectionComboBox.Text == "")
            {
                MessageBox.Show("Add a question first!",
                    "Question Creator Error",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Asterisk);
            }
            else
            {
                if (checkSaved())
                {
                    editing = true;
                    populateEditFields();
                    changesSaved = true;
                }
            }
        }

        /**Method: populateFieldsEditQuestion
         * Autofills the fields with all the relevant question data from the selected question within the QCQuestionSelectionComboBox
         * 
         */
        private void populateEditFields()
        {
            string[] editQuestion = (dataAccess.GetQuestion((int)questionIDList[QCQuestionSelectionComboBox.SelectedIndex])).Split('|');

            editQuestionID = int.Parse((string)editQuestion.GetValue(QUIZZERDB_QUESTION_QUESTIONID_INDEX));
            editSubCategoryID = int.Parse((string)editQuestion.GetValue(QUIZZERDB_QUESTION_SUBCATEGORYID_INDEX));

            QCTopicTextbox.Text = (string)editQuestion.GetValue(QUIZZERDB_QUESTION_TOPIC_INDEX);
            QCQuestionTextbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_TITLE_INDEX);

            QCDifficultyLevelComboBox.SelectedIndex = int.Parse((string)(editQuestion.GetValue(QUIZZERDB_QUESTION_DIFFICULTY_LEVEL_INDEX)));

            QCCategoryComboBox_SelectedIndexChanged(new object(), new EventArgs());
            setCategorySubCategoryEditing(editSubCategoryID);

            if (editQuestion.GetValue(QUIZZERDB_QUESTION_PUBLIC_INDEX).Equals("No"))
            {
                QCMakePublicCheckbox.Checked = false;
            }
            else
            {
                QCMakePublicCheckbox.Checked = true;
            }

            QCCorrectAnswerTextbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_CORRECT_ANSWER_INDEX);
            QCAlternative1Textbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_ALT_ANSWER1_INDEX);
            QCAlternative2Textbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_ALT_ANSWER2_INDEX);
            QCAlternative3Textbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_ALT_ANSWER3_INDEX);
            QCAlternative4Textbox.Text = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_ALT_ANSWER4_INDEX);
            editRating = int.Parse((String)editQuestion.GetValue(QUIZZERDB_QUESTION_RATING_INDEX));
            editFeedback = (String)editQuestion.GetValue(QUIZZERDB_QUESTION_FEEDBACK_INDEX);
        }

        /**Method: setCategorySubCategoryEditing
         * Finds the category of the question being edited and sets the correct index for QCCategoryComboBox
         * Then finds the subcategory of the question being edited and sets the correct index for QCSubCategoryComboBox
         * @param subCategoryID the ID of the subcategory of the question being edited
         */

        public void setCategorySubCategoryEditing(int subCategoryID)
        {
            int categoryEditID = int.Parse((string)(dataAccess.GetCategoryForSubCategory(subCategoryID)).Split('|').GetValue(QUIZZERDB_CAT_SUBCAT_CATEGORYID_INDEX));
            
            for (int catID = 0; catID < questionCategoryIDList.ToArray().Length; catID++)
            {
                if (categoryEditID == (int)questionCategoryIDList[catID])
                {
                    QCCategoryComboBox.SelectedIndex = catID;
                }
            }

            for (int subCatID = 0; subCatID < questionSubCategoryIDList.ToArray().Length; subCatID++)
            {
                if (subCategoryID == int.Parse((string)questionSubCategoryIDList[subCatID]))
                {
                    QCSubCategoryComboBox.SelectedIndex = subCatID;
                }
            }
        }

        /**Method: QCSaveButton - Click
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method saves the current question, checking to see if the question is a new question
         * or a question being edited.  This method also calls the checkValidQuestion() to see if there
         * are blank or invalid fields.  If there are invalid fields - then calls the blankFieldsError method.
         */

        private void QCSaveButton_Click(object sender, EventArgs e)
        {
            ArrayList missingFields = checkValidQuestion();
            if (missingFields.Count == 0)
            {
                if (editing)
                {
                    updateQuestion();
                }
                else
                {
                    saveNewQuestion();
                }
            }
            else
            {
                blankFieldsError(missingFields);
            }
            changesSaved = true;
        }

        /**Method checkValidQuestion
         * This method checks if certain fields are blank or invalid
         * @return the arraylist of error field names
         */

        private ArrayList checkValidQuestion()
        {
            ArrayList errorFormControls = new ArrayList();

            if (QCTopicTextbox.Text == "")
            {
                errorFormControls.Add("Topic");
            }
            if (QCQuestionTextbox.Text == "")
            {
                errorFormControls.Add("Question");
            }
            if (QCCorrectAnswerTextbox.Text == "")
            {
                errorFormControls.Add("Correct Answer");
            }
            if (QCAlternative1Textbox.Text == "")
            {
                errorFormControls.Add("Alternative 1");
            }
            if (QCDifficultyLevelComboBox.SelectedIndex == 0)
            {
                errorFormControls.Add("Difficulty");
            }
            if (QCSubCategoryComboBox.Text == "")
            {
                errorFormControls.Add("Subcategory");
            }
            if (QCCategoryComboBox.Text == "")
            {
                errorFormControls.Add("Category");
            }
            return (errorFormControls);
        }

        /**Method blankFieldsError
         * This method shows a error dialog box with all field names that are missing or blank
         * @param missingFields the arraylist of field names with blank or invalid fields.
         */

        private void blankFieldsError(ArrayList missingFields)
        {
            String errorMessage = "";

            for (int missingFieldsCounter = 0; missingFieldsCounter < missingFields.Count; missingFieldsCounter++)
            {
                errorMessage = String.Concat(
                    errorMessage,
                    "The ",
                    missingFields[missingFieldsCounter],
                    " field cannot be blank.\n");
            }

            MessageBox.Show(
                errorMessage,
                "Question Creator Error",
                MessageBoxButtons.OK,
                MessageBoxIcon.Asterisk);
        }

        /**Method: updateQuestion
         * This method calls the UpdateQuestion method in the Quizzer_Data_Access class 
         * in order to save and update a question that is being edited 
         */

        private void updateQuestion()
        {
            dataAccess.UpdateQuestion(
                editQuestionID,
                editSubCategoryID,
                QCTopicTextbox.Text,
                QCQuestionTextbox.Text,
                QCDifficultyLevelComboBox.SelectedIndex.ToString(),
                (QCMakePublicCheckbox.Checked) ? "Yes" : "No",
                QCCorrectAnswerTextbox.Text,
                QCAlternative1Textbox.Text,
                QCAlternative2Textbox.Text,
                QCAlternative3Textbox.Text,
                QCAlternative4Textbox.Text,
                editRating.ToString(),
                editFeedback,
                user_id);
        }

        /**Method: saveNewQuestion
         * This method saves the current question as a new question and adds it to the database via the Quizzer_Data_Access class
         * Sets the QCQuestionSelectionComboBox to the newly made question and sets the editing flag to true.
         */

        private void saveNewQuestion()
        {
            editQuestionID = dataAccess.getMaxQuestionID() + 1;

            dataAccess.NewQuestion(
                        int.Parse((String)questionSubCategoryIDList[QCSubCategoryComboBox.SelectedIndex]),
                        QCTopicTextbox.Text,
                        QCQuestionTextbox.Text,
                        QCDifficultyLevelComboBox.SelectedIndex.ToString(),
                        (QCMakePublicCheckbox.Checked) ? "Yes" : "No",
                        QCCorrectAnswerTextbox.Text,
                        QCAlternative1Textbox.Text,
                        QCAlternative2Textbox.Text,
                        QCAlternative3Textbox.Text,
                        QCAlternative4Textbox.Text,
                        initRating.ToString(),
                        initFeedback,
                        user_id);

            populateQCQuestionSelectionComboBox();
            QCQuestionSelectionComboBox.SelectedIndex = questionIDList.Count - 1;
            changesSaved = true;
            QCEditButton_Click(new object(), new EventArgs());
        }

        /**Method: QCExitButton - Click
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method exits the current screen and shows the previous form.
         * This method also calls the checkSaved() method to see if the user has saved the current question.
         */

        private void QCExitButton_Click(object sender, EventArgs e)
        {
            if (checkSaved())
            {
                this.Close();
            }
        }

        /**Method: QCNewQuestionButton - Click
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method sets the form fields back to the default settings when the user first opens the dialog box.
         * This method also calls the checkSaved() method to see if the user has saved the current question.
         */

        private void QCNewQuestionButton_Click(object sender, EventArgs e)
        {
            if (checkSaved())
            {
                editing = false;
                setDefaultComboBoxValues();

                QCQuestionTextbox.Text = "Cannot be blank!";
                QCTopicTextbox.Text = "Cannot be blank!";
                QCCorrectAnswerTextbox.Text = "Cannot be blank!";
                QCAlternative1Textbox.Text = "Cannot be blank!";
                QCAlternative2Textbox.Text = "";
                QCAlternative3Textbox.Text = "";
                QCAlternative4Textbox.Text = "";
                QCMakePublicCheckbox.Checked = false;

                changesSaved = true;
            }
        }

        /**Method: checkSaved
         * This method checks if there were any changes to any question fields.
         * If there are changes, then a dialog box appears asking if the user wants to save, not save, or cancel.
         * @return whether or not changes were saved
         */
        private Boolean checkSaved()
        {
            if (changesSaved == false)
            {
                DialogResult response = MessageBox.Show(
                    "Do you want to save first?",
                    "Question Creator Save Hero",
                    MessageBoxButtons.YesNoCancel,
                    MessageBoxIcon.Asterisk);

                if (response == DialogResult.Yes)
                {
                    changesSaved = true;

                    QCSaveButton_Click(new object(), new EventArgs());
                }
                else if (response == DialogResult.Cancel)
                {
                    changesSaved = false;
                }
                else
                {
                    changesSaved = true;
                }
            }
            return changesSaved;
        }

        /**Method: QCCategoryComboBox - SelectedIndexChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * Oddly, even though there is no code within the method, the QC form will not run without this method.
         */

        private void QuestionCreatorForm_Load(object sender, EventArgs e)
        {
        }

        /**Method: QCCategoryComboBox - SelectedIndexChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method checks if the QCCategoryComboBox has been changed in order to set the changesSaved flag to false 
         * This also calls to the populateQCSubcategoryComboBox with the current category id in order for the 
         * QCSubcategoryComboBox to successfully update the subcategories with the given selected category.
         */

        private void QCCategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            changesSaved = false;
            if (QCSubCategoryComboBox.Items.Count > 0)
            {
                populateQCSubcategoryComboBox((int)questionCategoryIDList[QCCategoryComboBox.SelectedIndex]);
            }
            else
            {
                populateQCSubcategoryComboBox(0);
            }
        }

        /**Method: QCSubCategoryComboBox - SelectedIndexChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCSubCategoryComboBox has been changed in order to set the changesSaved flag to false 
         */

        private void QCSubCategoryComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCTopicTextbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCTopicTextbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCTopicTextbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCQuestionTextbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCQuestionTextbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCQuestionTextbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCCorrectAnswerTextbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCCorrectAnswerTextbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCCorrectAnswerTextbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCAlternative1Textbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCAlternative1Textbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCAlternative1Textbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCAlternative2Textbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCAlternative2Textbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCAlternative2Textbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCAlternative3Textbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCAlternative3Textbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCAlternative3Textbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCAlternative4Textbox - TextChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCAlternative4Textbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCAlternative4Textbox_TextChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCSubCategoryComboBox - SelectedIndexChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCSubCategoryComboBox has been changed in order to set the changesSaved flag to false 
         */

        private void QCDifficultyLevelComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }

        /**Method: QCMakePublicCheckbox - CheckedChanged
         * 
         * This is an auto generated method by Visual Studio
         * 
         * This method is to simply check if the QCMakePublicCheckbox has been changed in order to set the changesSaved flag to false 
         */

        private void QCMakePublicCheckbox_CheckedChanged(object sender, EventArgs e)
        {
            changesSaved = false;
        }
    }
}
